package com.starmark.gateway.springcloud.provider.response;


import com.starmark.gateway.springcloud.provider.exception.ErrorType;
import org.springframework.http.HttpStatus;

/**
 * 错误异常返回
 *
 * @author starmark
 * <p>
 * 2018年12月26日
 */
public class ErrorResponseData extends Response {

    private String stackMsg;

    private ErrorResponseData(int code, String msg, String stackMsg) {
        super(code, msg);

        this.stackMsg = stackMsg;
    }


    public ErrorResponseData() {
        super(HttpStatus.INTERNAL_SERVER_ERROR);
    }

    public static ErrorResponseData newInstance(String msg) {
        return new ErrorResponseData(HttpStatus.INTERNAL_SERVER_ERROR.value(), msg, msg);
    }
    public static ErrorResponseData newInstance(ErrorType errorType, String stackMsg) {
        return new ErrorResponseData(errorType.getCode(),errorType.getMsg(), stackMsg);
    }


    public static ErrorResponseData newInstance(int code) {
        return new ErrorResponseData(code, null, null);
    }


    public static ErrorResponseData newInstance(int code, String msg) {
        return new ErrorResponseData(code, msg, null);
    }


    public static ErrorResponseData newInstance(int code, String msg, String stackMsg) {
        return new ErrorResponseData(code, msg, stackMsg);
    }

    public String getStackMsg() {
        return stackMsg;
    }

    public void setStackMsg(String stackMsg) {
        this.stackMsg = stackMsg;
    }

}